<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue测试</title>
  <style>
    .content {
      background: skyblue;
      width: 100px;
      height: 100px;
    }

    .fade-enter-active,
    .fade-leave-active {
      transition: opacity 3s;
    }

    .fade-enter,
    .fade-leave-to {
      opacity: 0;
    }
  </style>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <transition name="fade">
      <div v-if="isShow" class="content fade-enter-active"></div>
    </transition>
    <button type="button" @click="toggleEvent">切换显示</button>
  </div>
  <script type="text/javascript">
    var app = new Vue({
      el: '#app',
      data: {
        isShow: true
      },
      methods: {
        toggleEvent() {
          this.isShow = !this.isShow
        }
      }
    })
  </script>
</body>

</html>